package com.lzq.his.controller;

import com.lzq.his.domain.AB;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/math")
public class MathController {

    @PostMapping("/add")
    public int add(@Valid @RequestBody AB nums)
    {
        System.out.println(nums);
        int one = Integer.parseInt(nums.getOne());
        int two = Integer.parseInt(nums.getTwo());
        return one + two;
    }

    @PostMapping("/jian")
    public int jian(@Valid @RequestBody AB nums)
    {
        System.out.println(nums);
        int one = Integer.parseInt(nums.getOne());
        int two = Integer.parseInt(nums.getTwo());
        return one - two;
    }

    @PostMapping("/mult")
    public int mult(@Valid @RequestBody AB nums)
    {
        System.out.println(nums);
        int one = Integer.parseInt(nums.getOne());
        int two = Integer.parseInt(nums.getTwo());
        return one * two;
    }

    @PostMapping("/div")
    public int div(@Valid @RequestBody AB nums)
    {
        System.out.println(nums);
        int one = Integer.parseInt(nums.getOne());
        int two = Integer.parseInt(nums.getTwo());
        return one / two;
    }
}
